<template>
	<view class="bg" style="display: flex; flex-direction: row; justify-content: center; align-items: center; height: 100vh;">
		<view style="display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 10px; background-color: #fff; width: 85%; ">
			<image :src="centerMsg.headimg" style="width: 100px; height: 100px; border-radius: 50%; margin-top: 20px;"></image>
			<view class="nickName" style="margin-top: 10px;">
				{{centerMsg.nickname}}
			</view>
			<view class="nickName" style="margin-top: 10px; color: #000;">
				{{centerMsg.id? 'ID: ' + centerMsg.id:''}}
			</view>
			<image :src="paymentCodeUrl" style="width: 75%; margin-top: 10px; margin-bottom: 30px;" mode="widthFix">
		</view>
	</view>
</template>

<script>
	import {
		getPersonalCenter,
		getVersions,
		getAppConfigSync
	} from "../../api/index.js"
	export default {
		data() {
			return {
				centerMsg: {},
				paymentCodeUrl: '',
				intervalTimer: 0,
				imageURL: 'https://wx.2024csnl.com/static/qrcodebg.jpg'
			}
		},
		async onLoad() {
			
		},
		onHide() {
			if (this.intervalTimer > 0) {
				clearInterval(this.intervalTimer);
			}
		},
		onUnload() {
			if (this.intervalTimer > 0) {
				clearInterval(this.intervalTimer);
			}
		},
		async onShow() {
			await this.onGetPersonalCenter();
			await this.onGetPersonalCenter1();
			this.intervalTimer = setInterval(async () => {
				await this.onGetNeedPayOrder()
			}, 2000);
		},
		methods: {
			async onGetPersonalCenter1() {
				const res = await getPersonalCenter('s=/ApiZwyRequest/userinfo')
				const {
					data,
					status,
					msg
				} = res.data
				if (status == 1) {
					this.centerMsg = data
			
				} else {
					this.showToast(msg)
				}
			},
			async onGetPersonalCenter() {
				const res = await getPersonalCenter('s=/ApiMy/getmidqrcode')
				console.log(res)
				const {
					payqrcode,
					status,
					msg
				} = res.data
				if (status == 1) {
					this.paymentCodeUrl = payqrcode + "?t=" + new Date().getMilliseconds()
				} else {
					this.showToast(msg)
				}
			},
			async onGetNeedPayOrder() {
				const res = await getPersonalCenter('s=/ApiOrder/getneedpayorder')
				console.log(res)
				const {
					order_info,
					status,
					msg
				} = res.data
				if (status === 1) {
					if (order_info && !Array.isArray(order_info)) {
						clearInterval(this.intervalTimer)
						this.onSkip(`/business/pages/business_tab/face2FaceCodePay?bid=${order_info.bid}&orderid=${order_info.orderid}&payorderid=${order_info.payorderid}`)
					}

				} else {
					this.showToast(msg)
				}
			},
		}
	}
</script>

<style>
.bg{
	background:url(https://wx.2024csnl.com/static/qrcodebg.jpg) no-repeat;
	background-size:cover;
}
</style>